<template>
	<view>
		<template v-if="$_loginOrNot()">
			<template v-if="listFollowPostState == 'success'">
				<view class="list-interact">
					<view
						@click="$_To('post/post?pid='+item.pid)"
						class="for Flex"
						v-for="item in listFollowPost">
						<view
							class="left"
							@click.stop="$_To('user/user?uid=' + item.author.uid)">
							<image :src="item.author.avatar" mode="widthFix"></image>
						</view>
						<view class="right">
							<view class="nickname Zt-ShenLanSe">{{item.author.nickname?item.author.nickname:'?'}}
								<text class="P" :style="item.author.nicknameColor?'color:'+item.author.nicknameColor+';':''">{{item.author.roleName}}</text>
							</view>
							<!-- 文字摘要 -->
							<view class="title" v-if="item.title">{{item.title}}</view>
							<view class="content">{{$_filterHtml(item.content)}}</view>
							<!-- 图片 -->
							<view class="image Flex" v-if="item.files.images.length">
								<view
									@click.stop="$_picturePreview(index,item.files.images)"
									v-for="(images,index) in item.files.images">
									<image :src="images.imageRatioUrl" mode="widthFix"></image>
								</view>
							</view>
							<!-- 视频列表 -->
							<view class="video" v-if="!item.files.images.length && item.files.videos.length">
								<view class="image-cover">
									<image :src="item.files.videos[0].videoPosterUrl" mode="widthFix"></image>
								</view>
								<text class="Flex iconfont icon-play"></text>
							</view>
							<view class="group" v-if="item.group || item.hashtags">
								<view class="_group" v-if="item.group">
									<view><image :src="item.group.cover" mode="widthFix"></image></view>
									<text>{{item.group.gname}}</text>
								</view>
								<view class="_hashtag" v-if="item.hashtags.length">#{{item.hashtags[0].hname}}#</view>
							</view>
							<view
								class="post-info Flex"
								:style="!item.previewLikeUsers && !item.previewComments?'margin-bottom: 0;':''">
								<view class="_position" v-if="item.location && item.location.poi">
									<text class="iconfont icon-dingwei1"></text>
									<text class="_position_POI">{{item.location.poi}}</text>
								</view>
								<text class="P">{{item.createdTimeAgo}}</text>
								<view class="type Flex">
									<text class="Bj-LanSe iconfont icon-tupian" v-if="item.files.images.length"></text>
									<text class="Bj-HongSe iconfont icon-zhibo" v-if="item.files.videos.length"></text>
									<text class="Bj-LvSe iconfont icon-yuyin" v-if="item.files.audios.length"></text>
									<text class="Bj-BianKuangSe iconfont icon-gengduo"></text>
								</view>
							</view>
							<view class="like Bj-BeiJingSe" v-if="item.previewLikeUsers.length">
								<text class="iconfont icon-dianzan"></text>
								<template v-for="item_DianZan in item.previewLikeUsers">
									<text class="H3">{{item_DianZan.nickname}},</text>
								</template>
							</view>
							<view class="comment Bj-BeiJingSe" v-if="item.previewComments.length">
								<template v-for="item_PingLun in item.previewComments">
									<view class="_for">
										<text class="_nickname Zt-ShenLanSe">{{item_PingLun.author.nickname}}:</text>
										<text class="iconfont icon-yuyin" v-if="item_PingLun.files.audios.length"></text>
										<text>{{$_filterHtml(item_PingLun.content)}}</text>
									</view>
								</template>
							</view>
						</view>
					</view>
					<view
						@click="getPostList('more')"
						class="more">点击加载更多</view>
				</view>
			</template>
			<template v-if="listFollowPostState == 'loading'">
				<view class="skeleton-screen">
					<view class="left loading-css"></view>
					<view class="right">
						<view class="loading-css"></view>
						<view class="loading-css"></view>
						<view class="loading-css"></view>
					</view>
				</view>
				<view class="skeleton-screen">
					<view class="left loading-css"></view>
					<view class="right">
						<view class="loading-css"></view>
						<view class="loading-css"></view>
						<view class="loading-css"></view>
					</view>
				</view>
				<view class="skeleton-screen">
					<view class="left loading-css"></view>
					<view class="right">
						<view class="loading-css"></view>
						<view class="loading-css"></view>
						<view class="loading-css"></view>
					</view>
				</view>
			</template>
			<template v-if="listFollowPostState == 'empty'">
				<public-empty></public-empty>
			</template>
		</template>
		<template v-else>
			<public-not-logged-in></public-not-logged-in>
		</template>
	</view>
</template>

<script>
	export default {
		name:"public-follow-posts",
		data() {
			return {
				listFollowPost:[],
				listFollowPostPage:2,
				listFollowPostState:"loading",
			};
		},
		mounted(){
			if(this.$_loginOrNot()){
				this.getPostList();
			}
		},
		methods:{
			// 获取关注帖子列表
			getPostList(more){
				if(more == 'more'){uni.showLoading({ title: "加载中" });}
				this.$_Request(
					"GET","/api/v2/user/"+uni.getStorageSync('user').data.detail.uid+"/mark/follow/posts",
					{
						"whitelistKeys":"pid,author.uid,author.avatar,author.nickname,author.nicknameColor,author.roleName,title,content,files,group,hashtags,previewLikeUsers,previewComments,location,createdTimeAgo",
						"page":more == 'more' ? this.listFollowPostPage : "",
					},
					(res) => {
						if(more == 'more'){
							if(res.data.data.list.length){
								this.listFollowPost = this.listFollowPost.concat(res.data.data.list);
								this.listFollowPostPage++
								uni.hideLoading();
							}else{
								uni.showToast({
									title: "没有数据啦",
									icon: "none",
									duration: 1000
								});
							}
						}else{
							if(res.data.data.list.length){
								this.listFollowPost = res.data.data.list;
								this.listFollowPostState = "success"
							}else{
								this.listFollowPostState = "empty"
							}
						}
					}
				)
			},
		},
	}
</script>

<style lang="scss" scoped>
.list-interact{
	padding: 0 25rpx;
	.for{
		padding: 25rpx 0;
		border-bottom: 1rpx solid $BeiJingSe;
		.left{
			width: 80rpx;
			height: 80rpx;
			overflow: hidden;
			border-radius: 15rpx;
		}
		.right{
			flex: 1;
			margin-left: 25rpx;
			.nickname{
				font-weight: bold;
				.P{
					font-weight: normal;
					padding-left: 15rpx;
				}
			}
			.title{
				font-weight: bold;
				margin-top: 5rpx;
				display: -webkit-box;
				/*!autoprefixer:off*/
				-webkit-box-orient: vertical;
				/*autoprefixer:on*/
				-webkit-line-clamp: 1;
				overflow: hidden;
			}
			.content{
				word-break: break-all;
				margin-top: 5rpx;
				display: -webkit-box;
				/*!autoprefixer:off*/
				-webkit-box-orient: vertical;
				/*autoprefixer:on*/
				-webkit-line-clamp: 3;
				overflow: hidden;
			}
			.image{
				flex-wrap: wrap;
				margin-top: 10rpx;
				view{
					width: 194rpx;
					height: 150rpx;
					overflow: hidden;
					box-shadow: 0 0 1rpx $ZhanWeiSe;
					margin-top: 10rpx;
				}
				view:nth-child(2),view:nth-child(5),view:nth-child(8){
					margin: 10rpx 10rpx 0 10rpx;
				}
				// #ifdef MP-WEIXIN
				view{
					margin-top: 8rpx;
				}
				view:nth-child(2),view:nth-child(5),view:nth-child(8){
					margin: 8rpx 8rpx 0 8rpx;
				}
				// #endif
			}
			.video{
				margin-top: 20rpx;
				width: 100%;
				height: 300rpx;
				overflow: hidden;
				border-radius: 10rpx;
				position: relative;
				.image-cover{
					position: absolute;
					top: 0;
					left: 0;
					z-index: 1;
					width: 100%;
					height: 300rpx;
					overflow: hidden;
				}
				.icon-play{
					position: absolute;
					top: 0;
					left: 0;
					z-index: 2;
					width: 100%;
					height: 300rpx;
					align-items: center;
					justify-content: center;
					color: #FFF;
					text-shadow: 0 0 1rpx #000;
					font-size: 100rpx;
					line-height: 100rpx;
					background-color:rgba(0,0,0,0.5);
				}
			}
			.group{
				display: flex;
				align-items: center;
				margin-top: 25rpx;
				._group{
					display: flex;
					align-items: center;
					background: $BeiJingSe;
					border-radius: 100rpx;
					margin-right: 20rpx;
					view{
						width: 45rpx;
						height: 45rpx;
						overflow: hidden;
						border-radius: 100%;
					}
					text{
						font-size: 22rpx;
						line-height: 22rpx;
						padding: 0 20rpx 0 15rpx;
					}
				}
				._hashtag{
					display: flex;
					align-items: center;
					border-radius: 100rpx;
					height: 45rpx;
					background: $BeiJingSe;
					font-size: 22rpx;
					line-height: 22rpx;
					padding: 0 15rpx;
					margin-right: 20rpx;
				}
			}
			.post-info{
				margin: 25rpx 0;
				align-items: center;
				._position{
					display: flex;
					align-items: center;
					line-height: 22rpx;
					margin-right: 10rpx;
					text{
						font-size: 22rpx;
						line-height: 22rpx;
						color: $ZhanWeiSe;
					}
					.iconfont{
						margin-right: 5rpx;
					}
					._position_POI{
						max-width: 350rpx;
						display: -webkit-box;
						/*!autoprefixer:off*/
						-webkit-box-orient: vertical;
						/*autoprefixer:on*/
						-webkit-line-clamp: 1;
						overflow: hidden;
					}
				}
				.type{
					flex: 1;
					align-items: center;
					justify-content: flex-end;
					text{
						margin-left: 10rpx;
						color: #FFF;
						font-size: 18rpx;
						line-height: 18rpx;
						padding: 5rpx;
						border-radius: 2rpx;
					}
					.icon-gengduo{
						display: flex;
						align-items: center;
						justify-content: center;
						color: $YuanSe;
						padding: 0 10rpx;
						height: 26rpx;
					}
				}
			}
			.like{
				padding: 15rpx 20rpx;
				line-height: 38rpx;
				border-bottom: 1px solid $BianKuangSe;
				text{
					color: $ShenLanSe;
				}
				.icon-dianzan{
					font-size: 32rpx;
					padding: 0 5rpx 0 0;
					position: relative;
					top: .5rpx;
				}
				.H3{
					line-height: 38rpx;
					margin-right: 10rpx;
				}
			}
			.comment{
				padding: 10rpx 0 15rpx 0;
				border-radius: 10rpx;
				._for{
					padding: 5rpx 25rpx 0 25rpx;
					line-height: 40rpx;
					text{
						font-size: 28rpx;
					}
					._nickname{
						flex-shrink: 0;
						padding-right: 10rpx;
					}
					.icon-yuyin{
						font-size: 22rpx;
						line-height: 22rpx;
						padding-right: 5rpx;
						color: $LvSe;
					}
				}
			}
		}
	}
	.more{
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		line-height: 28rpx;
		color: $ZhanWeiSe;
		padding: 35rpx 0;
	}
}
.skeleton-screen{
	display: flex;
	border-bottom: 1rpx solid $BeiJingSe;
	padding: 25rpx 0;
	.left{
		width: 80rpx;
		height: 80rpx;
		overflow: hidden;
		border-radius: 15rpx;
		flex-shrink: 0;
	}
	.right{
		flex: 1;
		margin-left: 25rpx;
		view:nth-child(1){
			width: 100%;
			height: 40rpx;
		}
		view:nth-child(2){
			width: 100%;
			height: 120rpx;
			margin: 15rpx 0;
		}
		view:nth-child(3){
			width: 100%;
			height: 150rpx;
		}
	}
}
</style>